function init_grid () {
    $("#downlines").flexigrid({
        url: _webroot+'/members/downlines',
        dataType: 'json',
        colModel: [
            { display: 'ID', name: 'id', width: 60, sortable: true, align: 'right' },
            { display: 'Country', name: 'country', width: 95, sortable: true, align: 'left' },
            { display: 'Agent Name', name: 'fullname', width: 120, sortable: true, align: 'left' },
            { display: 'Telephone', name: '', width: 80, sortable: true, align: 'left' },
            { display: 'Tree Level', name: 'level', width: 80, sortable: true, align: 'left' },
            { display: 'View', name: 'actions', width: 30, align: 'center' }
        ],
        searchitems: [
            { display: 'Order ID', name: 'id', isdefault: true },
            { display: 'Amount', name: 'amount' },
            { display: 'BV', name: 'total_pv' }
        ],
        sortname: 'level',
        sortorder: 'asc',
        usepager: true,
        title: 'Downlines',
        useRp: true,
        rp: 15,
        showTableToggleBtn: false,
        width: 780,
        height: 300
    });
} // init_grid

function reload_grid () {
    $("#downlines").flexReload();
} // reload_grid

function message (msg, focus) {
    alert(msg);

    if (typeof focus != 'undefined') {
        Ext.fly(focus).focus();
    }
} // message

function init () {
    init_grid();
} // init